import http from './index'

//活动列表接口
export function activityList_api(params) {
	const token = window.localStorage.getItem('token')
	return http.post('/bizManagement/activityPub/queryPageToManage',
		{
		page: params.page,
		activityName: params.activityName,
		minScore: params.minScore,
		maxScore: params.maxScore,
		activityType: params.activityType,
		recommend: params.recommend != "" ? (params.recommend == '推荐' ? 'Y' : 'N')  : ""
		},
		{
			headers: {
				'Authorization': token,
				'Content-Type': 'application/json'
			}
		},
		)
		.then(res => {
			return res.data
		})
}

//删除活动接口
export function delete_api(params) {
	const token = window.localStorage.getItem('token')
	return http.post('/bizManagement/activityPub/delete',
		{
		ids: params.id
		},
		{
			headers: {
				'Authorization': token,
				'Content-Type': 'application/json'
			}
		},
		)
		.then(res => {
			return res.data
		})
}

//更新是否推荐接口
export function updateRecommend_api(params) {
	const token = window.localStorage.getItem('token')
	console.log("====>", params)
	return http.post('/bizManagement/activityPub/updateRecommend',
		{
		id: params.id
		},
		{
			headers: {
				'Authorization': token,
				'Content-Type': 'application/json'
			}
		},
		)
		.then(res => {
			return res.data
		})
}

//新增活动接口
export function createActive_api(params) {
	const token = window.localStorage.getItem('token')
	return http.post('/bizManagement/activityPub/create',
		{
		activityName: params.activityName,
		activityType: params.activityType,
		activityInformation: params.activityInformation,
		recommend: params.recommend ? 'Y' : 'N',
		publicityMap: params.publicityMap,
		score: params.score
		},
		{
			headers: {
				'Authorization': token,
				'Content-Type': 'application/json'
			}
		},
		)
		.then(res => {
			return res.data
		})
}


//修改活动接口
export function modifyActive_api(params) {
	const token = window.localStorage.getItem('token')
	return http.post('/bizManagement/activityPub/modify',
		{
		id: params.id,
		activityName: params.activityName,
		activityType: params.activityType,
		activityInformation: params.activityInformation,
		recommend: params.recommend ? 'Y' : 'N',
		publicityMap: params.publicityMap,
		score: params.score
		},
		{
			headers: {
				'Authorization': token,
				'Content-Type': 'application/json'
			}
		},
		)
		.then(res => {
			return res.data
		})
}

//查询活动详情接口
export function getDetailsById_api(params) {
	const token = window.localStorage.getItem('token')
	return http.get('/bizManagement/activityPub/getDetailsById?id=' + params,
		{
			headers: {
				'Authorization': token,
				'Content-Type': 'application/json'
			}
		},
		)
		.then(res => {
			return res.data
		})
}